package com.changan.stumgr.controller;

import com.changan.stumgr.pojo.Grade;
import com.changan.stumgr.pojo.Student;
import com.changan.stumgr.service.GradeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
public class GradeController {
    @Autowired
    private GradeService gradeService;

    @RequestMapping("/show")
    public String showDid(HttpSession session, HttpServletRequest request){
        List<Grade> gradeList = gradeService.listGrade();
        if(gradeList==null){
            return "list";
        }
      Student s=  (Student)request.getAttribute("student");
if(null==s){
    System.out.println("=============null============");
}
            System.out.println(s.getName());
        session.setAttribute("gradeList",gradeList);
        request.setAttribute("gradeList",gradeList);
        return "add";
    }
}
